package com.zlzkj.app.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.zlzkj.app.mapper.ShopMapper;
import com.zlzkj.app.model.Role;
import com.zlzkj.app.model.Shop;
import com.zlzkj.core.sql.Row;
import com.zlzkj.core.sql.SQLBuilder;
import com.zlzkj.core.mybatis.SqlRunner;


@Service
@Transactional
public class ShopService {


	@Autowired
	private SqlRunner sqlRunner;

	@Autowired
	private ShopMapper mapper;

	public List<Row> findShopById(int adminId) {// 查询计划
//		String sql = "select s.shop_name,s.address,s.phone,s.wechat,s.status from x_shop s,x_admin a where s.id=a.shop_id and a.id="+adminId;
		String sql="select shop_name,address,phone,wechat,status,time from x_shop";
		
		System.out.println("sql======"+sql);

		return sqlRunner.select(sql, 1);
	}
	

	public Integer insertShop(Shop shop) {
		
		return mapper.insert(shop);
	}
	

	
	public Integer update(Shop shop) throws Exception{
		
		return mapper.updateByPrimaryKey(shop);
	}
	

	
	public Shop findById(Integer id){
		return mapper.selectByPrimaryKey(id);
	}
	

	public Integer delete(Integer id){
		return mapper.deleteByPrimaryKey(id);
	}
	

}
